using CsGL.OpenGL;
using System;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;

namespace TagTool.OpenGL 
{

	public abstract class Model : GL, IDisposable 
	{
		App app;
		String name;
		
		public Model(String name)
		{
			this.name = name;
			
		}
		
		public App App
		{
			set { app = value; }
			get { return app; }
		}
		
		public void Dispose() 
		{
			Dispose(true);																// We've Manually Called For A Dispose
			GC.SuppressFinalize(this);													// Prevent Being Added To The Finalization Queue
		}

		public void Dispose(bool disposing) 
		{
			
		}

		~Model() 
		{
			Dispose(false);																// We've Automatically Called For A Dispose
		}

		public virtual void Draw() 
		{
		}
		
		/**
		 * This method is provided to place some code 
		 * to shut the rendering of the scene.
		 * e.g. stop timers.
		 */
		protected abstract void ShutDown();
		
		/**
		 * This Method should initialize the perspective an general
		 * settings for initialization of openGL.
		 * 
		 * Here can be done some other initializing code for 
		 * an concrete Model. eg starting a FrameTimer
		 */
		public abstract void Initialize();

		public virtual void WindowsForm(App app) 
		{
			this.app = app;
			app.Form = new AppForm(app, name);
			app.Form.Show();
			app.Form.Closing += new CancelEventHandler(Closing);
		}

		protected void Closing(Object sender, CancelEventArgs e)
		{
			ShutDown();
		}

		public abstract void Reshape(int width, int height);

		
	}
}
